-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LLD][ELF] Skip non-SHF_ALLOC sections when checking max VA and max VA difference in relaxOnce() #145863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…A difference in relaxOnce() For non-SHF_ALLOC sections, sh_addr is set to 0. Skip sections without SHF_ALLOC flag, so `minVA` will not be set to 0 with non-SHF_ALLOC sections, and the size of non-SHF_ALLOC sections will not contribute to `maxVA`.
@llvm/pr-subscribers-lld @llvm/pr-subscribers-lld-elf Author: Mingjie Xu (Enna1) ChangesFor non-SHF_ALLOC sections, sh_addr is set to 0. Full diff: https://github.com/llvm/llvm-project/pull/145863.diff 1 Files Affected:
diff --git a/lld/ELF/Arch/X86_64.cpp b/lld/ELF/Arch/X86_64.cpp
index 163505102d0ec..488f4803b2cb4 100644
--- a/lld/ELF/Arch/X86_64.cpp
+++ b/lld/ELF/Arch/X86_64.cpp
@@ -320,6 +320,8 @@ bool X86_64::deleteFallThruJmpInsn(InputSection &is, InputFile *file,
bool X86_64::relaxOnce(int pass) const {
uint64_t minVA = UINT64_MAX, maxVA = 0;
for (OutputSection *osec : ctx.outputSections) {
+ if (!(osec->flags & SHF_ALLOC))
+ continue;
minVA = std::min(minVA, osec->addr);
maxVA = std::max(maxVA, osec->addr + osec->size);
}
|
This is correct but can you edit /x86-64-gotpc-relax-too-far.s to make this testable? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
Thanks for the review!
Tried but didn't make it... The max VA and max VA difference checks are for early return. Do you have any suggestions? Thanks! |
You are right that the SHF_ALLOC condition just skips some check and does not change the behavior. Then why does it matter? Do you find a scenario where having the condition improves performance? |
I'm looking for strategies that alleviate relocation overflow pressure. While trying to understand 9d6ec28 and f3c4dae, I found the max VA difference takes non-SHF_ALLOC sections into account, which is a bit confusing.
I will test with internal cases to see if there is any performance improvement. |
For non-SHF_ALLOC sections, sh_addr is set to 0.
Skip sections without SHF_ALLOC flag, so
minVA
will not be set to 0 with non-SHF_ALLOC sections, and the size of non-SHF_ALLOC sections will not contribute tomaxVA
.